import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import {JVxeTypes,JVxeColumn} from '/@/components/jeecg/JVxeTable/types'
//列表数据
export const columns: BasicColumn[] = [
  //  {
  //   title: '单据类型ID',
  //   align:"center",
  //   dataIndex: 'billTypeId'
  //  },
   {
    title: '单据类型',
    align:"center",
    dataIndex: 'billTypeName'
   },
   {
    title: '单据编号',
    align:"center",
    sorter: true,
    dataIndex: 'billCode'
   },
  //  {
  //   title: '业务员ID',
  //   align:"center",
  //   dataIndex: 'salesmanId'
  //  },
   {
    title: '业务员',
    align:"center",
    dataIndex: 'salesmanName'
   },
  //  {
  //   title: '仓库ID',
  //   align:"center",
  //   dataIndex: 'warehouseId'
  //  },
   {
    title: '仓库',
    align:"center",
    dataIndex: 'warehouseName'
   },
   {
    title: '业务日期',
    align:"center",
    sorter: true,
    dataIndex: 'businessDate',
    customRender:({text}) =>{
      return !text?"":(text.length>10?text.substr(0,10):text)
    },
   },
   {
    title: '单据状态',
    align:"center",
    dataIndex: 'billStatus',
    width: 100,
    customRender:({text}) =>text==0?'开立':text==1?'审核':text==-1?'作废':'',
   },
   {
    title: '备注',
    align:"center",
    dataIndex: 'remark'
   },
   {
    title: '第三方编码',
    align:"center",
    dataIndex: 'thirdPartyCode',
    ifShow: false
   },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
	{
      label: "单据编号",
      field: "billCode",
      component: 'Input',
      colProps: {span: 6},
 	},
	{
      label: "业务员",
      field: "salesmanName",
      component: 'Input',
      colProps: {span: 6},
 	},
	{
      label: "仓库",
      field: "warehouseName",
      component: 'Input',
      colProps: {span: 6},
 	},
	{
      label: "业务日期",
      field: "businessDate",
      component: 'DatePicker',
      colProps: {span: 6},
 	},
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '单据类型ID',
    field: 'billTypeId',
    component: 'Input',
    show:false
  },
  {
    label: '单据类型',
    field: 'billTypeName',
    component: 'Input',
    slot:'billTypeSlot',
    dynamicRules: () => {
      return [
        { required: true, message: '请选择单据类型!' },
      ];
    },
  },
  {
    label: '单据编号',
    field: 'billCode',
    component: 'Input',
  },
  {
    label: '业务员ID',
    field: 'salesmanId',
    component: 'Input',
    show:false
  },
  {
    label: '业务员',
    field: 'salesmanId',
    component: 'JSelectUserByDept',
    componentProps: {
      isRadioSelection:true,
      rowKey: 'id',
      labelKey: 'realname',
      showButton: false
    },
  },
  {
    label: '仓库ID',
    field: 'warehouseId',
    component: 'Input',
    show:false
  },
  {
    label: '仓库',
    field: 'warehouseName',
    component: 'Input',
    slot:'warehouseSlot'
  },
  {
    label: '业务日期',
    field: 'businessDate',
    component: 'DatePicker',
  },
  // {
  //   label: '单据状态 0开立 1审核 -1作废',
  //   field: 'billStatus',
  //   component: 'InputNumber',
  // },
  {
    label: '备注',
    field: 'remark',
    component: 'Input',
  },
  {
    label: '第三方编码',
    field: 'thirdPartyCode',
    component: 'Input',
    ifShow: false
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];
//子表单数据
//子表表格配置
export const busBeginPeriodStockItemColumns: JVxeColumn[] = [
    {
      title: '期初库存ID',
      key: 'beginPeriodStockId',
      type: JVxeTypes.hidden,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '行号',
      key: 'rowNum',
      type: JVxeTypes.input,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '料品ID',
      key: 'materialId',
      type: JVxeTypes.hidden,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '料品编号',
      key: 'materialCode',
      type: JVxeTypes.slot,
      slotName:'materialSlot',
      width:"200px",
    },
    {
      title: '料品',
      key: 'materialName',
      type: JVxeTypes.normal,
      width:"200px",
    },
    {
      title: '库存单位ID',
      key: 'unitId',
      type: JVxeTypes.hidden,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '库存单位',
      key: 'unitName',
      type: JVxeTypes.slot,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '数量',
      key: 'quantity',
      type: JVxeTypes.inputNumber,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '单价',
      key: 'price',
      type: JVxeTypes.inputNumber,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '成本',
      key: 'cost',
      type: JVxeTypes.inputNumber,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '仓库ID',
      key: 'warehouseId',
      type: JVxeTypes.hidden,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '仓库',
      key: 'warehouseName',
      type: JVxeTypes.input,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '备注',
      key: 'remark',
      type: JVxeTypes.input,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '第三方编码',
      key: 'thirdPartyCode',
      type: JVxeTypes.hidden,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
  ]


/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[]{
// 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}